package top.zhangjianyong.tools.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.zhangjianyong.tools.parm.RemindItemAddParam;
import top.zhangjianyong.tools.parm.RemindItemUpdateParam;
import top.zhangjianyong.tools.service.api.RemindItemService;
import top.zhangjianyong.tools.user.VerifyUser;
import top.zhangjianyong.tools.utils.ApiResponse;

/**
 * @author ： zhangjianyong
 * @date ： 2021/11/1 下午7:21
 */
@SuppressWarnings("rawtypes")
@RestController
@RequestMapping("/remindItem")
public class RemindItemController {

    @Autowired
    private RemindItemService remindItemService;

    @VerifyUser(login = false)
    @GetMapping("/get/{id}")
    public ApiResponse get(@PathVariable String id) {
        return remindItemService.get(id);
    }

    @PostMapping("/add")
    public ApiResponse add(@RequestBody RemindItemAddParam remindItemAddParam) {
        return remindItemService.add(remindItemAddParam);
    }

    @PostMapping("/update/{id}")
    public ApiResponse update(@PathVariable Long id, @RequestBody RemindItemUpdateParam remindItemUpdateParam) {
        remindItemUpdateParam.setId(id);
        return remindItemService.update(remindItemUpdateParam);
    }

    @PostMapping("/delFlag/{id}/{flag}")
    public ApiResponse delFlag(@PathVariable String id,
                               @PathVariable int flag) {
        return remindItemService.delFlag(id, flag);
    }

    @PostMapping("/del/{id}")
    public ApiResponse delFlag(@PathVariable String id) {
        return remindItemService.del(id);
    }

    @PostMapping("/page/{page}/{size}")
    public ApiResponse page(@PathVariable int page,
                            @PathVariable int size) throws Exception {
        return remindItemService.page(page, size);
    }

    @VerifyUser(login = false)
    @GetMapping("/close/{id}")
    public ApiResponse close(@PathVariable Long id, @RequestParam(value = "uuid", defaultValue = "") String uuid) throws Exception {
        return remindItemService.close(id, uuid);
    }

    @VerifyUser(login = false)
    @GetMapping("/closeNoCheck/{id}")
    public ApiResponse closeNoCheck(@PathVariable Long id) throws Exception {
        return remindItemService.closeNoCheck(id);
    }

    @VerifyUser(login = false)
    @GetMapping("/reset")
    public ApiResponse reset() {
        return remindItemService.resetAll();
    }
}
